# eric7.Plugins.CheckerPlugins.CodeStyleChecker.Imports.ImportsChecker

Module implementing a checker for import statements.

### Global Attributes

None

### Classes

ImportsChecker | Class implementing a checker for import statements.

### Functions

None

## ImportsChecker

Class implementing a checker for import statements.

### Derived from

CodeStyleTopicChecker

### Class Attributes

Category
Codes

### Class Methods

None

### Methods

ImportsChecker | Constructor
__checkBannedImport | Private method to check import of banned modules.
__checkBannedRelativeImports | Private method to check if relative imports are banned.
__checkLocalImports | Private method to check local imports.
__checkUnnecessaryAlias | Private method to check unnecessary import aliases.
__compileUnstructuredGlob | Private method to convert a pattern to a regex such that ".*" matches zero or more modules.
__isModuleBanned | Private method to check, if the given module name banned.
__tidyImports | Private method to check various other import related topics.

### Static Methods

None

#### ImportsChecker (Constructor)

ImportsChecker(source, filename, tree, select, ignore, expected, repeat, args)

Constructor

source (list of str)
  source code to be checked
filename (str)
  name of the source file
tree (ast.Module)
  AST tree of the source code
select (list of str)
  list of selected codes
ignore (list of str)
  list of codes to be ignored
expected (list of str)
  list of expected codes
repeat (bool)
  flag indicating to report each occurrence of a code
args (dict)
  dictionary of arguments for the various checks

#### ImportsChecker.__checkBannedImport

__checkBannedImport(node)

Private method to check import of banned modules.

node (ast.AST)
  reference to the node to be checked

#### ImportsChecker.__checkBannedRelativeImports

__checkBannedRelativeImports(node)

Private method to check if relative imports are banned.

node (ast.AST)
  reference to the node to be checked

#### ImportsChecker.__checkLocalImports

__checkLocalImports()

Private method to check local imports.

#### ImportsChecker.__checkUnnecessaryAlias

__checkUnnecessaryAlias(node)

Private method to check unnecessary import aliases.

node (ast.AST)
  reference to the node to be checked

#### ImportsChecker.__compileUnstructuredGlob

__compileUnstructuredGlob(module)

Private method to convert a pattern to a regex such that ".*" matches zero or more modules.

module (str)
  module pattern to be converted

Return:
  compiled regex

Return Type:
  re.regex object

#### ImportsChecker.__isModuleBanned

__isModuleBanned(moduleName)

Private method to check, if the given module name banned.

moduleName (str)
  module name to be checked

Return:
  flag indicating a banned module

Return Type:
  bool

#### ImportsChecker.__tidyImports

__tidyImports()

Private method to check various other import related topics.

Up